<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>用户列表</title>
    <link rel="stylesheet" href="static/css/bootstrap.min.css">
</head>
<body>
<h1 style="text-align: center">用户列表</h1>
<div class="container">
    <div class="row">
        <div class="col-4">
            菜单
        </div>
        <div class="col-8">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户名</th>
                        <th>密码</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <c:forEach var="user" items="${users.list}" varStatus="state">
                        <tr>
                            <td>${state.count}</td>
                            <td>${user.username}</td>
                            <td>${user.password}</td>
                            <td>
                                <a href="delete?id=${user.id}">删除</a>
                                <a href="update?id=${user.id}">修改</a>
                            </td>
                        </tr>
                    </c:forEach>
                </tbody>
                <tfoot>
                    <tr class="table-dark">
                        <td colspan="4">
                            <nav aria-label="Page navigation example">
                                <ul class="pagination">
                                    <c:choose>
                                        <c:when test="${users.hasPreviousPage}">
                                            <li class="page-item">
                                                <a class="page-link" href="user?num=1">首页</a>
                                            </li>
                                        </c:when>
                                        <c:otherwise>
                                            <li class="page-item disabled">
                                                <a class="page-link">首页</a>
                                            </li>
                                        </c:otherwise>
                                    </c:choose>
                                    <c:choose>
                                        <c:when test="${users.hasPreviousPage}">
                                            <li class="page-item">
                                                <a class="page-link" href="user?num=${users.prePage}">上一页</a>
                                            </li>
                                        </c:when>
                                        <c:otherwise>
                                            <li class="page-item disabled">
                                                <a class="page-link">上一页</a>
                                            </li>
                                        </c:otherwise>
                                    </c:choose>
                                    </li>
                                    <c:forEach items="${users.navigatepageNums}" var="pageNum">
                                        <c:choose>
                                            <c:when test="${users.pageNum eq pageNum}">
                                                <li class="page-item active">
                                                    <a class="page-link">${pageNum}</a>
                                                </li>
                                            </c:when>
                                            <c:otherwise>
                                                <li class="page-item">
                                                    <a class="page-link" href="user?num=${pageNum}">${pageNum}</a>
                                                </li>
                                            </c:otherwise>
                                        </c:choose>
                                    </c:forEach>
                                    <c:choose>
                                        <c:when test="${users.hasNextPage}">
                                            <li class="page-item">
                                                <a class="page-link" href="user?num=${users.nextPage}">下一页</a>
                                            </li>
                                        </c:when>
                                        <c:otherwise>
                                            <li class="page-item disabled">
                                                <a class="page-link">下一页</a>
                                            </li>
                                        </c:otherwise>
                                    </c:choose>
                                    <c:choose>
                                        <c:when test="${users.hasNextPage}">
                                            <li class="page-item">
                                                <a class="page-link" href="user?num=${users.pages}">尾页</a>
                                            </li>
                                        </c:when>
                                        <c:otherwise>
                                            <li class="page-item disabled">
                                                <a class="page-link">尾页</a>
                                            </li>
                                        </c:otherwise>
                                    </c:choose>
                                    </li>
                                </ul>
                            </nav>
                            <%--            <c:if test="${users.hasPreviousPage}">--%>
                            <%--                <a href="user?num=${users.prePage}">上一页</a>--%>
                            <%--            </c:if>--%>
                            <%--            <c:if test="${!users.hasPreviousPage}">--%>
                            <%--                <a>上一页</a>--%>
                            <%--            </c:if>--%>


                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>

</div>
</body>
</html>
